﻿(function () {
    $('#fastEl').click(function () {
        layer.open({
            type: 1,
            title: '快速新建',
            shadeClose: true,
            shade: 0.8,
            area: ['880px', '80%'],
            scrollbar: false,
            content: $('#fastEditHtml') //捕获的元素
        });
    });
})();

$('#submitEl').click(function () {
    var datas = $('#fastEditFormEl').serializeArray();
    console.log(datas);
    $.post('savefastedit', datas).success(function () {
        var date = new Date();
        $('#msg').text('保存成功-' + date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds())
        $('input[name="title"]').val('');
        $('textarea[name="detail"]').val('');

    }).error(function () {
        alert('服务器错误');
    });
});

$('.fast-edit-link').click(function () {
    var $this = $(this);
    var id = $this.attr('data-id');
    layer.open({
        type: 2,
        title: '快速编辑',
        shadeClose: true,
        shade: 0.8,
        area: ['880px', '80%'],
        scrollbar: false,
        content: 'fastedit/' + id //iframe的url
    });
});

function toRecycle(postId) {
    var params = [{ name: 'postIds', value: postId }]
    if (!postId)
        params = $('#table-form').serializeArray();

    if (params.length === 0) return;

    $.post('/post/torecycle', params).success(function () {
        window.location.reload();
    }).error(function () { });
}

function totalCheck(evt) {
    var isChecked = $(evt).is(':checked');
    $('#table-form').find('input[name="postIds"]').attr('checked', isChecked);
}